﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using CE.Provider;
public partial class controls_usrCompanyLogoByServices : System.Web.UI.UserControl
{
    //    100	Car Insurance
    //    200	Home Refinance
    //    300	Credit Card
    //    400	Personal Loan
    //    500	Personal Accident
    //    600	Travel Insurance
    private string strProviderTypeId;
    private int intlimitCount;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserTypeId] != null)
        {
            if (Session[CE.Global.General.UserTypeId].ToString() == Convert.ToInt32(CE.Global.CEUserType.Provider).ToString())
            {
                divCompanyLogo.Visible = false;
            }
        }
        //divCompanyLogo.Visible = false;
    }

    public string CompanyProviderTypeId
    {
        get { return strProviderTypeId; }
        set { strProviderTypeId = value; }
    }

    public int LogoLimitCount
    {
        get { return intlimitCount; }
        set { intlimitCount = value; }
    }

    protected override void OnPreRender(EventArgs e)
    {
        //SetEnabled();

        if (strProviderTypeId != string.Empty)
        {
            LoadProviderLogo();
        }
    }

    private void LoadProviderLogo()
    {
        CompanyLogo _companylogo = new CompanyLogo();
        CompanyDB _companydb = new CompanyDB();
        ProviderCompanyServicesList _pserviceslist = new ProviderCompanyServicesList();
        ProviderCompanyServicesDB _pservicesdb = new ProviderCompanyServicesDB();
        _pserviceslist = _pservicesdb.GetProviderCompanyListByProviderTypeId(Convert.ToInt32(strProviderTypeId));
        int _count = 0;
        if (_pserviceslist != null)
        {
            foreach (ProviderCompanyServices _pservices in _pserviceslist)
            {
                Image imgCompanyLogo = new Image();
                _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                imgCompanyLogo.ImageUrl = _companylogo.CompanyLogoServerUrl;
                imgCompanyLogo.AlternateText = _companylogo.CompanyName;
                imgCompanyLogo.ToolTip = _companylogo.CompanyName;
                HtmlGenericControl _spanCtrl = new HtmlGenericControl("span");
                _spanCtrl.Attributes.Add("class", "partnerlogo");
                _spanCtrl.Controls.Add(imgCompanyLogo);
                divCompanyLogo.Controls.Add(_spanCtrl);
                _count++;
                if (_count >= intlimitCount)
                {
                    HtmlGenericControl _divClear = new HtmlGenericControl("div");
                    _divClear.Attributes.Add("class", "clear");
                    divCompanyLogo.Controls.Add(_divClear);
                    break;
                }
                //if (_count == 1)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo1.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 2)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo2.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 3)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo3.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 4)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo4.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 5)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo5.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 6)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo6.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
            }
        }
    }
}
